/****************************************************************************
**
****************************************************************************/

#include "formPassword.h"
#include "ui_formPassword.h"

FormPassword::FormPassword(QWidget *parent) : QDialog(parent),
    ui(new Ui::FormPassword)
{
    ui->setupUi(this);
}

FormPassword::~FormPassword()
{
    delete ui;
}

void FormPassword::ClearText()
{
    ui->TextLabel->clear();
    password_.clear();
}

void FormPassword::on_N1PushButton_clicked()
{
    if (reinput_) {
        reinput_ = false;
        ClearText();
    }

    ui->TextLabel->setText(ui->TextLabel->text() + "*");

    password_.append(ui->N1PushButton->text());
}

void FormPassword::on_N2PushButton_clicked()
{
    if (reinput_) {
        reinput_ = false;
        ClearText();
    }

    ui->TextLabel->setText(ui->TextLabel->text() + "*");

    password_.append(ui->N2PushButton->text());
}

void FormPassword::on_N3PushButton_clicked()
{
    if (reinput_) {
        reinput_ = false;
        ClearText();
    }

    ui->TextLabel->setText(ui->TextLabel->text() + "*");

    password_.append(ui->N3PushButton->text());
}

void FormPassword::on_N4PushButton_clicked()
{
    if (reinput_) {
        reinput_ = false;
        ClearText();
    }

    ui->TextLabel->setText(ui->TextLabel->text() + "*");

    password_.append(ui->N4PushButton->text());
}

void FormPassword::on_N5PushButton_clicked()
{
    if (reinput_) {
        reinput_ = false;
        ClearText();
    }

    ui->TextLabel->setText(ui->TextLabel->text() + "*");

    password_.append(ui->N5PushButton->text());
}

void FormPassword::on_N6PushButton_clicked()
{
    if (reinput_) {
        reinput_ = false;
        ClearText();
    }

    ui->TextLabel->setText(ui->TextLabel->text() + "*");

    password_.append(ui->N6PushButton->text());
}

void FormPassword::on_N7PushButton_clicked()
{
    if (reinput_) {
        reinput_ = false;
        ClearText();
    }

    ui->TextLabel->setText(ui->TextLabel->text() + "*");

    password_.append(ui->N7PushButton->text());
}

void FormPassword::on_N8PushButton_clicked()
{
    if (reinput_) {
        reinput_ = false;
        ClearText();
    }

    ui->TextLabel->setText(ui->TextLabel->text() + "*");

    password_.append(ui->N8PushButton->text());
}

void FormPassword::on_N9PushButton_clicked()
{
    if (reinput_) {
        reinput_ = false;
        ClearText();
    }

    ui->TextLabel->setText(ui->TextLabel->text() + "*");

    password_.append(ui->N9PushButton->text());
}

void FormPassword::on_N0PushButton_clicked()
{
    if (reinput_) {
        reinput_ = false;
        ClearText();
    }

    ui->TextLabel->setText(ui->TextLabel->text() + "*");

    password_.append(ui->N0PushButton->text());
}

void FormPassword::on_EnterPushButton_clicked()
{
    QString password = tr("090909");

    if (password == password_) {
        hide();
        emit CheckSuccess();
    } else {
        ui->TextLabel->setText(tr("安全密码错误，请重新输入或取消。"));
        reinput_ = true;
    }
}

void FormPassword::on_CancelPushButton_clicked()
{
    hide();
}
